---
title: GitHub
---

This example goes over how to load data from a GitHub repository.
You can set the `GITHUB_ACCESS_TOKEN` environment variable to a GitHub access token to increase the rate limit and access private repositories.

## Setup

The GitHub loader requires the [ignore npm package](https://www.npmjs.com/package/ignore) as a peer dependency. Install it like this:

```bash npm
npm install @langchain/community @langchain/core ignore
```

## Usage

import Github from "/snippets/javascript-integrations/examples/document_loaders/github.mdx";

<Github />

The loader will ignore binary files like images.

### Using .gitignore Syntax

To ignore specific files, you can pass in an `ignorePaths` array into the constructor:

import GithubIgnorePaths from "/snippets/javascript-integrations/examples/document_loaders/github_ignore_paths.mdx";

<GithubIgnorePaths />

### Using a Different GitHub Instance

You may want to target a different GitHub instance than `github.com`, e.g. if you have a GitHub Enterprise instance for your company.
For this you need two additional parameters:

- `baseUrl` - the base URL of your GitHub instance, so the githubUrl matches `<baseUrl>/<owner>/<repo>/...`
- `apiUrl` - the URL of the API endpoint of your GitHub instance

import GithubCustomInstance from "/snippets/javascript-integrations/examples/document_loaders/github_custom_instance.mdx";

<GithubCustomInstance />

### Dealing with Submodules

In case your repository has submodules, you have to decide if the loader should follow them or not. You can control this with the boolean `processSubmodules` parameter. By default, submodules are not processed.
Note that processing submodules works only in conjunction with setting the `recursive` parameter to true.

import GithubSubmodules from "/snippets/javascript-integrations/examples/document_loaders/github_submodules.mdx";

<GithubSubmodules />

Note, that the loader will not follow submodules which are located on another GitHub instance than the one of the current repository.

### Stream large repository

For situations where processing large repositories in a memory-efficient manner is required. You can use the `loadAsStream` method to asynchronously streams documents from the entire GitHub repository.

import GithubStream from "/snippets/javascript-integrations/examples/document_loaders/github_stream.mdx";

<GithubStream />
